<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title>父组件传值给子组件</title>
		<script src="js/vue.js" type="text/javascript" charset="utf-8"></script>
	</head>
	<body>
		<div id="app">
			 <child-component parent-data="123" :title="parentTitle" content='当前父组件为Root'></child-component>
			 <parent-component>  </parent-component>
		</div>
		<script>
			Vue.component('parent-component',{
				data:function(){
					return {
						content:'父组件的数据'
					}
				},
				template:`
				<div>
				   <h4>{{content}}</h4>
				   <sub-component :SubContent="content"></sub-component>
				</div>
				 `
			});
			
			Vue.component('sub-component', {
				props:['SubContent'],
				data: function() {
					return {
						msg: '子组件本身的数据'
					}
				},
				template: `
				   <div>
				    <h2>{{SubContent}}</h2>
				    <h4>{{msg}}</h4>
				   </div>
				 `
			});
			
			Vue.component('child-component', {
				props:['title','content','ParentData'],
				data: function() {
					return {
						msg: '子组件本身的数据'
					}
				},
				template: `
				   <div>
				    <h2>{{content}}</h2>
				    <h4>{{msg}}</h4>
					<h5>{{title}}</h5>
				    <h5>{{ParentData}}</h5>
				   </div>
				 `
			});


			let vm = new Vue({
				el: '#app',
				data:{
					parentTitle:'父组件提供的数据'
				}

			});
		</script>
	</body>
</html>
